package com.example.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.entity.Menu;
import com.example.demo.entity.dto.ExportExcelDto;
import com.example.demo.entity.vo.PageVo;
import com.example.demo.util.MyExcelUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description：通用接口控制器.
 * @author：lw
 * @create_time：2024/2/28
 **/


@Tag(name="通用接口")
@ApiSupport(order = 0)
@RestController
@RequestMapping(value = "/admin/common")
public class CommonController {

    @Operation(summary = "导出excel")
    @ApiOperationSupport(order = 1,author = "lw")
    @PostMapping(value = "/exportExcel")
    public void exportExcel(@RequestBody ExportExcelDto exportExcelDto, HttpServletResponse response) {
        PageVo<Map<String,Object>> pageVo=new PageVo<>(exportExcelDto.getList(),null,null,null);
        MyExcelUtil.export(response,pageVo, exportExcelDto.getHeader(),exportExcelDto.getTitle());
    }
}
